We will use the pared down dataset created earlier.
flu_visits =
read_csv("./ed_flu_tidy.csv") %>%
mutate(mod_zcta = as.factor(mod_zcta))
## Parsed with column specification:
## cols(
## extract_date = col_date(format = ""),
## date = col_date(format = ""),
## mod_zcta = col_double(),
## total_ed_visits = col_double(),
## ili_pne_visits = col_double(),
## ili_pne_admissions = col_double(),
## pct_visits = col_double(),
## pct_adm = col_double()
## )
Merging with our zip code-by-borough dataset will allow us to aggregate within zip codes and boroughs, and compare to other data sets with zip code data.
zip_boro =
read_csv("./nyc_zip_boro.csv") %>%
janitor::clean_names() %>%
mutate(zip_codes = as.factor(zip_codes))
## Parsed with column specification:
## cols(
## Borough = col_character(),
## `ZIP Codes` = col_double()
## )
visits_w_zip =
left_join(flu_visits, zip_boro, by = c("mod_zcta" = "zip_codes"))
Create a map using plotly.
visits_w_zip %>%
mutate(text_label = str_c(
"Date: ", date,
"\n% ILI Visits: ", pct_visits,
"\n% ILI Admissions: ", pct_adm)) %>%
plot_ly(
x = ~date, y = ~total_ed_visits, color = ~borough, text = ~text_label,
alpha = 0.3, type = "scatter", mode = "markers"
)
## Warning: `arrange_()` is deprecated as of dplyr 0.7.0.
## Please use `arrange()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.